<template>
	<view class="wrap" style="background:#f5f5f5;">
		<u-navbar style="position:absolute;" :title="$t('index.yqhy')" title-width="340" :border-bottom="false" back-icon-color="#fff" title-color="#fff" :background="{ backgroundColor: 'transparent' }"></u-navbar>
		<view class="tom-container">
			<image class="top_img" src="/static/new_images/invite-header.png" mode=""></image>
			<view class="cell_shu">
				<view class="cell_shu_tiele">{{$t('wdyq')}}</view>
				<view class="cell_shu_item">
					<view class="item">
						<view class="top">
							<u-icon name="haoyou" color="#333" custom-prefix="custom-icon" size="28" style="margin-right: 10rpx;"></u-icon>
							<text>{{$t('yqrs')}}</text>
						</view>
						<view class="bottom">{{myInvite.inviteNum}}</view>
					</view>
					<view class="item">
						<view class="top">
							<u-icon name="liwu" color="#333" custom-prefix="custom-icon" size="30" style="margin-right: 10rpx;"></u-icon>
							<text>{{$t('jlje')}} (USDT)</text>
						</view>
						<view class="bottom">{{myInvite.award}}</view>
					</view>
				</view>
			</view>
			<view class="panel">
				<view class="cell">
					<view class="cell_tips">
						{{$t('wdfl')}}<text class="text">{{data.profitRewardRate}}</text>
					</view>
					<view class="cell_item">
						<view class="left">{{$t('yqm')}}</view>
						<view class="right" @tap="copy(data.inviteCode)">
							<text>{{data.inviteCode}}</text>
							<u-icon name="fuzhi" color="#0032B7" custom-prefix="custom-icon" size="28" style="margin-left: 20rpx;"></u-icon>
						</view>
					</view>
					<view class="cell_item">
						<view class="left">{{$t('yqlj')}}</view>
						<view class="right" @tap="copy(data.copyInviteUrl)">
							<text class="text">{{data.inviteUrl}}</text>
							<u-icon name="fuzhi" color="#0032B7" custom-prefix="custom-icon" size="28" style="margin-left: 20rpx;"></u-icon>
						</view>
					</view>
				</view>
				<view class="cell_btn">
					<view class="btn" @tap="toPage('/pages/User/Share/Share')">
						{{$t('ljyq')}}
					</view>
					<view class="btn btn2" @tap="Recode">
						{{$t('mdmyq')}}
					</view>
				</view>
			</view>
		</view>
		<u-popup v-model="show" mode="center"  border-radius="10">
			<view class="LnviteFriends_popup">
				<view class="title">{{$t('mdmyq')}}</view>
				<tki-qrcode class="img" ref="qrcode" :val="data.copyInviteUrl" :size="284" :onval="true" :loadMake="true" :loadingText="$t('loading.title')"
				 :showLoading="true"/>
			</view>
		</u-popup>
		<image class="bottom-bg" src="/static/new_images/invite-bg.png"></image>
	</view>
</template>

<script>
export default {
	data() {
		return {
			data:{},
			myInvite:{},
			show:false,
		};
	},
	onShow() {
		this.indexData();
	},
	methods: {
		// 上拉加载
		indexData(){
			uni.showLoading({
				mask: true,
				title: this.$t('loading.title')
			});
			this.$api.userApi
				.getRecommendEnrolHome()
				.then(res => {
					this.data = res.data
					this.myInvite = res.data.myInvite
					uni.hideLoading();
				}).catch(res =>{
					uni.hideLoading();
				})
		},
		copy(e){
			this.$utils.copy(e)
		},
		Recode(){
			this.show = true;
		},
		toPage(link) {
			uni.navigateTo({
				url: link
			});
		},
	}
};
</script>

<style lang="scss" scoped>
	.panel{
		position:relative;
		z-index: 10;
	}
.tom-container {
	background-color: #fff;
	.top_img{
		width: 100%;
		height: 480rpx;
	}
	.cell{
		margin: 0rpx $nr-padd;
		border-radius: 10rpx;
		box-sizing: border-box;
		padding: 20rpx 30rpx;
		background-image: url('/static/new_images/back-bg.png');
		background-position: top left;
		background-size: 100% 100%;
		box-shadow: 0 0 10rpx 0 #e3e3e3;
		.cell_tips{
			width: 280rpx;height: 74rpx;
			padding: 20rpx 30rpx 20rpx 0;
			border-radius: 10rpx;
			font-size: 28rpx;
			font-weight: bold;
			color: $tom-text-color;
			display: flex;
			align-items: center;
			margin-bottom: 30rpx;
			.text{
				font-size: 36rpx;
				color: #F7582B;
				margin-left: 10rpx;
			}
		}
		.cell_item{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin: 16rpx 0rpx 0rpx;
			.left{
				font-size: 28rpx;
				font-weight: bold;
			}
			.right{
				display: flex;
				align-items:center;
				padding: 8rpx 20rpx;
				border-radius: 10rpx;
				background-color: rgba(51, 102, 153, 0.3);
				font-size: 28rpx;
				font-weight: bold;
				color: #fff;
				.text{
					max-width: 360rpx;
					overflow: hidden; /*自动隐藏文字*/
					text-overflow: ellipsis;/*文字隐藏后添加省略号*/
					white-space: nowrap;/*强制不换行*/
				}
			}
		}
	}
	.cell_btn{
		display: flex;
		justify-content: space-between;
		margin: 30rpx $nr-padd 84rpx $nr-padd;
		.btn{
			width: 100%;height: 86rpx;
			line-height: 84rpx;
			border-radius: 10rpx;
			background-color: $text-color;
			text-align: center;
			width: 100%;
			color: #fff;
			font-size: 32rpx;font-weight: bold;
		}
		.btn2{
			background-color:#fff;
			border: 2rpx solid $text-color;
			color: $text-color;
			margin-left: 50rpx;
		}
	}
	.cell_shu{
		background-image: url('/static/new_images/LnviteFriendsbg.png');
		background-position: top left;
		background-size: 100% 100%;
		margin: $nr-padd;
		background-color: #eaeaef;
		border-radius: 10rpx;
		padding: 30rpx;
		.cell_shu_tiele{
			font-weight: 800;
			font-size: 36rpx;
		}
		.cell_shu_item{
			display: flex;
			justify-content: space-between;
			margin-top: 40rpx;
			.item{
				width: 100%;
				text-align: center;
				.top{
					font-size: 28rpx;
				}
				.bottom{
					font-size: 36rpx;
					color: $text-color;
					font-weight: bold;
					margin-top: 20rpx;
				}
			}
		}
	}
	
}
.LnviteFriends_popup{
	padding: $nr-padd;
	text-align: center;
	
	.title{
		font-size: 36rpx;
		font-weight: bold;
		margin-bottom: $nr-padd;
		
	}
	.img{
		width: 300rpx;height: 300rpx;
	}
}
.bottom-bg{
	position:fixed;
	width:100%;
	height:250rpx;
	left:0;
	bottom:0;
	z-index: 1;
}
</style>
